package com.zjbti.myactivity;

import android.content.Intent;
import android.os.Bundle;
import android.util.Log;
import android.view.View;
import android.widget.Toast;

import androidx.annotation.Nullable;
import androidx.appcompat.app.AppCompatActivity;

public class MainActivity extends AppCompatActivity {

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        Log.i("MainActivity", "调用onCreate()");
    }
    @Override
    protected void onStart() {
        super.onStart();
        Log.i("MainActivity", "调用onStart()");
    }

    @Override
    protected void onStop() {
        super.onStop();
        Log.i("MainActivity", "调用onStop()");
    }

    @Override
    protected void onDestroy() {
        super.onDestroy();
        Log.i("MainActivity", "调用onDestroy()");
    }

    @Override
    protected void onPause() {
        super.onPause();
        Log.i("MainActivity", "调用onPause()");
    }

    @Override
    protected void onResume() {
        super.onResume();
        Log.i("MainActivity", "调用onResume()");
    }

    @Override
    protected void onRestart() {
        super.onRestart();
        Log.i("MainActivity", "调用onRestart()");
    }
    public void startPage(View view){
        //新建意图
        Intent intent = new Intent(MainActivity.this,SecondActivity.class);
        Intent intent2=new Intent();
        intent2.setAction("com.zjbti.SecondActivity.START_ACTIVITY");
        intent2.setAction("com.zjbti.FrithActivity.START_ACTIVITY");

        //使用意图，传输数据
        intent.putExtra("name","han");

        //数据的回传
         startActivityForResult(intent,1);
        //使用意图打开页面
//        startActivity(intent);
    }
    @Override
    protected void onActivityResult(int requestCode, int resultCode, Intent data) {
        super.onActivityResult(requestCode, resultCode, data);
        if (requestCode==1&&resultCode==2){
            String acquiredData = data.getStringExtra("data");
            Toast.makeText(MainActivity.this,acquiredData,Toast.LENGTH_SHORT).show();

        }
    }



}